package com.leyou.item.clients;

import com.leyou.common.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {

    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> pageQuery(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "id", required = false) Long id,
            @RequestParam(value = "categoryId", required = false) Long cid,
            @RequestParam(value = "brandId", required = false) Long bid,
            @RequestParam(value = "saleable", required = false) Boolean saleable);


    /**
     * 根据spuId查询对应的sku的集合
     *
     * @param spuId
     * @return
     */
    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> listSkuBySpu(
            @RequestParam("id") Long spuId);

    /**
     * 根据商品id或是否可搜索查询对应的规格参数
     *
     * @param id
     * @param searching
     * @return
     */
    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> queryParam(
            @RequestParam("id") Long id,
            @RequestParam(value = "searching", required = false) Boolean searching);


    /**
     * 根据品牌id的集合查询对应的品牌的集合
     *
     * @param ids
     * @return
     */
    @GetMapping("/brand/list")
    List<BrandDTO> listBrandByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据分类id的集合查询分类的集合
     *
     * @param ids
     * @return
     */
    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIds(
            @RequestParam("ids") List<Long> ids);



    @GetMapping("/goods/spu/{id}")
    SpuDTO querySpuById(@PathVariable("id") Long id);



    @GetMapping("/goods/spu/detail")
    SpuDetailDTO querySpuDetailById(@RequestParam("id") Long spuId);


    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuBySpuId(@RequestParam("id") Long spuId);



    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id") Long id);



    @GetMapping("/spec/of/category")
    List<SpecGroupDTO> querySpecList(@RequestParam("id") Long cid);



    @GetMapping("/goods/sku/list")
    List<SkuDTO> listSkuByIds(@RequestParam("ids") List<Long> ids);

    @PutMapping("/goods/stock/minus")
    Void minusStock(@RequestBody Map<Long,Integer> cartsMap);


    /**
     * 批量加库存
     *
     * @param cartsMap
     * @return
     */
    @PutMapping("/goods/stock/plus")
    Void plusStock(@RequestBody Map<Long, Integer> cartsMap);
}
